#pragma once
#include <map>
#include <utility>
#include <atlstr.h>
#include "ICommand.h"

/** sorting command in algorithm
1. sort
	1. sort
	2. stable_sort
	3. partial_sort
*/

using namespace std;

class CCommond : public ICommand
{
public:
	CCommond(){};
	virtual ~CCommond(){};
	virtual void Run(){};
	virtual CString GetCommondName(){return "command";};
};

class CSortCommand : public ICommand
{
public:
	CSortCommand();
	virtual ~CSortCommand();
	virtual void Run();
	virtual CString GetCommondName(){return "sort";};
};

class CStable_sortCommand : public ICommand
{
public:
	CStable_sortCommand();
	virtual ~CStable_sortCommand();
	virtual void Run();
	virtual CString GetCommondName(){return "stable_sort";};
};

class CPartial_sortCommand : public ICommand
{
public:
	CPartial_sortCommand();
	virtual ~CPartial_sortCommand();
	virtual void Run();
	virtual CString GetCommondName(){return "partial_sort";};
};

template<typename T>
struct ReleaseEx
{
	void operator()(const T& member)
	{
		if(NULL != member.second)
			delete member.second;
	}
};

class CmutaAlgoDemo
{
public:
	CmutaAlgoDemo(void);
	~CmutaAlgoDemo(void);
	bool ShowCommondResult(const CString& strCommondName);
private:
	void RegistCommond();
	void Release();
	pair<CString,ICommand*> Comp(ICommand* pFace);
private:
	map<CString,ICommand*> m_mapCommond;
};